package com.dyz.myBatis.daoImp;

import com.dyz.myBatis.dao.UserMapper;
import com.dyz.myBatis.model.User;
import com.dyz.myBatis.model.UserExample;
import com.ibatis.sqlmap.client.SqlMapClient;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;


import java.util.List;

/**
 * Created by kevin on 2016/6/17.
 */
public class UserDaoImp implements UserMapper {
    private SqlMapClient sqlMapClient;
    private SqlSessionFactory sqlSessionFactory;
    public UserDaoImp(SqlSessionFactory sqlSessionFactory){
        this.sqlSessionFactory = sqlSessionFactory;
    }
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param example
     * @mbggenerated
     */
    @Override
    public int countByExample(UserExample example) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param example
     * @mbggenerated
     */
    @Override
    public int deleteByExample(UserExample example) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param fId
     * @mbggenerated
     */
    @Override
    public int deleteByPrimaryKey(Integer fId) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @mbggenerated
     */
    @Override
    public int insert(User record) {
        int flag = 0;
            SqlSession sqlSession = sqlSessionFactory.openSession();
            try {
                UserMapper studentMapper = sqlSession.getMapper(UserMapper.class);
                flag = studentMapper.insert(record);
                sqlSession.commit();
            } catch (Exception e) {
                    e.printStackTrace();
            }finally {
                sqlSession.close();
            }
        return flag;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @mbggenerated
     */
    @Override
    public int insertSelective(User record) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param example
     * @mbggenerated
     */
    @Override
    public List<User> selectByExample(UserExample example) {
        return null;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param fId
     * @mbggenerated
     */
    @Override
    public User selectByPrimaryKey(Integer fId) {
        return null;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @param example
     * @mbggenerated
     */
    @Override
    public int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @param example
     * @mbggenerated
     */
    @Override
    public int updateByExample(@Param("record") User record, @Param("example") UserExample example) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @mbggenerated
     */
    @Override
    public int updateByPrimaryKeySelective(User record) {
        return 0;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @param record
     * @mbggenerated
     */
    @Override
    public int updateByPrimaryKey(User record) {
        return 0;
    }
}
